package com.mayi.zds.dao;

import com.mayi.zds.dao.provider.CouponProvider;
import com.mayi.zds.entity.Coupon;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.UpdateProvider;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @ClassName CouponDAO
 * @Description TODO
 * @Author zhong
 * @Date 2019/12/25 0025 下午 10:58
 * @Version 1.0
 */
@Repository
public interface CouponDAO {

    /**
     * 修改优惠劵的状态为已经使用
     * @Author zhong
     * @Date 2019/12/25 23:15:54
     * @param ids 优惠券的ID数组
     * @return void
     **/
    @UpdateProvider(type = CouponProvider.class,method = "updateStatusToUsedBitch")
    public void updateStatusToUsedBitch(String[] ids);

    /**
     * 修改优惠劵的状态为正常
     * @Author zhong
     * @Date 2019/12/25 23:15:54
     * @param ids 优惠券的ID数组
     * @return void
     **/
    @UpdateProvider(type = CouponProvider.class,method = "updateStatusToNotUseBitch")
    public void updateStatusToNotUseBitch(String[] ids);

    /**
     * 查询在订单所使用的优惠券
     * @Author zhong
     * @Date 2019/12/26 00:15:24
     * @param oid 订单ID
     * @return java.util.List<com.mayi.zds.entity.Coupon>
     **/
    @Select("SELECT * FROM zds_coupon WHERE order_id=#{oid}")
    public List<Coupon> getListByOrderId(String oid);

    @Select("select from zds_coupon where business_id=#{businessId}")
    /**
     * @description: 获取商家用优惠券
     * @params: [businessId]
     * @return: java.util.List<com.mayi.zds.entity.Coupon>
     * @author: 胡飞
     * @time: 2019/12/27 15:37
     */
    public List<Coupon> getByBusiness(String businessId);

    @Insert("insert to zds_coupon ")
    public void add();
}
